package com.bfl.sa.common.utils;

import org.apache.commons.lang3.time.DateFormatUtils;

import java.util.Calendar;
import java.util.Date;

public class DateUtils extends org.apache.commons.lang3.time.DateUtils {

    private DateUtils(){}

    private static Calendar getCalendar(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar;
    }

    private static int getHours(Date date) {
        return getCalendar(date).get(Calendar.HOUR);
    }

    private static int getMinutes(Date date) {
        return getCalendar(date).get(Calendar.MINUTE);
    }

    private static int getSeconds(Date date) {
        return getCalendar(date).get(Calendar.SECOND);
    }

    public static void setHours(Date dest, Date src) {
        setHours(dest, getHours(src));
    }

    public static void setMinutes(Date dest, Date src) {
        setMinutes(dest, getMinutes(src));
    }

    public static void setSeconds(Date dest, Date src) {
        setSeconds(dest, getSeconds(src));
    }

    public static String format(Date date, String pattern) {
        return DateFormatUtils.format(date, pattern);
    }
}
